<?php
class Menu_model extends CI_Model{
	function Menu_model(){
		parent::__construct();
	}
	
	/**
	 * 
	 * Get all front end menu
	 * @param $lang
	 */
	function getFrontEndMenu($lang){
		$data = array();
		
		$this->db->select('ml.menu_name, m.link');
		$this->db->from('menus m');
		$this->db->where('m.public','1');
		$this->db->where('m.type','1');
		$this->db->where('m.menu_id_ref',NULL);
		$this->db->order_by('m.order');
		$this->db->join('menu_languages ml','m.id = ml.menu_id');
		$this->db->join('languages l','l.id = ml.language_id AND l.code =\''.$lang. '\'');
		$q = $this->db->get();
		
		if($q->num_rows()){
			$data = $q->result_array();
		}
		
		$q->free_result();
		
		return $data;
		
	}
}